package com.example.test1024;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
    private EditText usnedit ,psdedit ;
    private Button intbtn ,fruits;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        setListener();

    }

    private void setListener() {
        fruits.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


            }
        });


        intbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //定义一个string型来获取输入框里的内容
                String usn =usnedit.getText().toString().trim() ;
                String psd=psdedit.getText().toString().trim() ;
                //实现跳转
                Intent intent =new Intent(MainActivity.this,
                        ShowActivity.class) ;
                //存入数据
                intent.putExtra("usn",usn) ;
                intent.putExtra("psd",psd);
                startActivity(intent);

            }
        });

    }

    private void initView() {
        usnedit=findViewById(R.id.usnedit) ;
        psdedit=findViewById(R.id.psdedit) ;
        intbtn=findViewById(R.id.intbtn) ;
        fruits=findViewById(R.id.fruits);


    }
}